POV-Ray : Newsgroups : povray.general : Function woes : Re: Function woes Server Time
3 Aug 2024 22:19:08 EDT (-0400)
  Re: Function woes  
From: ABX
Date: 17 Sep 2003 04:41:07
Message: <987gmv88j224bu0ajmhqc3dr3s5pclbbuc@4ax.com>
On Wed, 17 Sep 2003 10:14:23 +0200, Martin Magnusson
<lov### [at] frustratedhousewiveszzncom> wrote:
> Then I'd like to use it in an isosurface, but it gives unexpected 
> results. Using the macro below does what I want. I would expect the two 
> lines inside the function{} to be equal, but when using the one that is 
> commented out here, I just get a flat surface. Can somebody tell me why?

You did wrong assumption that x flows magically from isosurface to Gauss
function. x used within function code is basically reference to first
parameter of _current_ function, y is second one, z is third one. So you have
to write your code as follow:

#declare Gauss =
function(x,y,z,X1, Z1, S) {
   exp( -1 * ( pow(x-X1, 2) + pow(z-Z1, 2) ) / (2*pow(S, 2)) )
}

#macro Node( Centre_x, Centre_z, Spread )
isosurface
{
   function {
     y - Gauss( x,y,z, Centre_x, Centre_z, Spread )
   }
   contained_by {
     sphere{ <Centre_x, 0, Centre_z>, Spread*5 }
   }
   pigment{ rgbt < 1, 0, 0, 0.5> }
}
#end

I did not checked this but should work now as expected.

ABX


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.